add_library(mock_ls_tablet_service SHARED
  mock_ls_tablet_service.cpp)
target_link_libraries(mock_ls_tablet_service PUBLIC oceanbase)

add_library(mock_access_service SHARED
  mock_access_service.cpp)
target_link_libraries(mock_access_service PUBLIC oceanbase)

add_library(truncate_info_helper ob_truncate_info_helper.cpp)
target_include_directories(truncate_info_helper PUBLIC
  ${CMAKE_SOURCE_DIR}/unittest ${CMAKE_SOURCE_DIR}/mittest)
target_link_libraries(truncate_info_helper PUBLIC ob_base mockcontainer)

# add_library(mock_ft_parser SHARED
#   mock_ft_parser.cpp)
# target_link_libraries(mock_ft_parser PUBLIC oceanbase)

function(storage_unittest case)
  ob_unittest(${ARGV})
  target_link_libraries(${case} PRIVATE mockcontainer)
endfunction()

function(storage_unittest_longer_timeout case)
  ob_unittest(${ARGV})
  target_link_libraries(${case} PRIVATE mockcontainer)
  set_tests_properties(${case} PROPERTIES TIMEOUT 600)
endfunction()

function(storage_dml_unittest case)
  ob_unittest(${ARGV})
  target_link_libraries(${case} PRIVATE mockcontainer mock_ls_tablet_service mock_access_service)
endfunction()

function(storage_fts_unittest case)
  ob_unittest(${ARGV})
  target_link_libraries(${case} PRIVATE mockcontainer)
endfunction()

add_subdirectory(mockcontainer)
add_subdirectory(transaction)
add_subdirectory(tx)
add_subdirectory(blocksstable)
add_subdirectory(direct_load)
add_subdirectory(utl_file)
add_subdirectory(tx_table)
add_subdirectory(ddl)
add_subdirectory(share_storage)
add_subdirectory(sslog)
add_subdirectory(column_store_replica)
add_subdirectory(fts)

storage_unittest(test_io_manager_v1)
storage_unittest(test_io_manager)
storage_unittest(test_iocb_pool)
storage_unittest(test_ob_col_map)
storage_unittest(test_placement_hashmap)
storage_unittest(test_parallel_external_sort)
storage_unittest(test_i_store)
storage_unittest(test_sstable_merge_info_mgr)
storage_unittest(test_sample_filter)
#storage_unittest(test_row_sample_iterator)
#storage_unittest(test_table_store_stat_mgr)
storage_unittest(test_tenant_tablet_stat_mgr)
storage_unittest(test_truncate_info)
target_link_libraries(test_truncate_info PRIVATE truncate_info_helper)
storage_unittest(test_tenant_compaction_mem_pool)
storage_dml_unittest(test_uncommit_tx_info)
storage_unittest(test_compaction_memory_context)
storage_unittest(test_tablet_table_store)
#storage_unittest(test_dag_size)
storage_unittest(test_handle_cache)
#storage_unittest(test_log_replay_engine replayengine/test_log_replay_engine.cpp)
storage_unittest(test_hash_performance)
storage_unittest(test_row_fuse)
if(OB_BUILD_CLOSE_MODULES)
# test_keybtree takes too long time on github ci platform(more than 2hours)
storage_unittest_longer_timeout(test_keybtree memtable/mvcc/test_keybtreeV2.cpp)
endif()
storage_unittest(test_query_engine memtable/mvcc/test_query_engine.cpp)
#storage_unittest(test_memtable_basic memtable/test_memtable_basic.cpp)
storage_unittest(test_mvcc_callback memtable/mvcc/test_mvcc_callback.cpp)
# storage_unittest(test_mds_compile multi_data_source/test_mds_compile.cpp)
storage_unittest(test_mds_list multi_data_source/test_mds_list.cpp)
storage_unittest(test_mds_node multi_data_source/test_mds_node.cpp)
storage_unittest(test_mds_new_ctx_deserialized multi_data_source/test_mds_new_ctx_deserialized.cpp)
# storage_unittest(test_mds_row multi_data_source/test_mds_row.cpp)
# storage_unittest(test_mds_unit multi_data_source/test_mds_unit.cpp)
storage_unittest(test_mds_table multi_data_source/test_mds_table.cpp)
storage_unittest(test_mds_table_flush multi_data_source/test_mds_table_flush.cpp)
storage_unittest(test_mds_table_flusher multi_data_source/test_mds_table_flusher.cpp)
storage_unittest(test_mds_table_forcelly_remove multi_data_source/test_mds_table_forcelly_remove.cpp)
storage_unittest(test_mds_dump_kv multi_data_source/test_mds_dump_kv.cpp)
#storage_unittest(test_multiple_merge)
#storage_unittest(test_memtable_multi_version_row_iterator memtable/test_memtable_multi_version_row_iterator.cpp)
#storage_unittest(test_new_table_store)
storage_unittest(test_mds_table_handle multi_data_source/test_mds_table_handle.cpp)
storage_unittest(test_is_old_mds multi_data_source/test_is_old_mds.cpp)
storage_unittest(test_fixed_size_block_allocator)
storage_unittest(test_dag_warning_history)
storage_unittest(test_storage_schema)
storage_unittest(test_checkpoint_diagnose checkpoint/test_checkpoint_diagnose.cpp)
#storage_unittest(test_storage_schema_mgr)
#storage_unittest(test_create_tablet_memtable test_create_tablet_memtable.cpp)
storage_unittest(test_tenant_meta_obj_pool test_tenant_meta_obj_pool.cpp)
storage_unittest(test_tablet_pointer_map test_tablet_pointer_map.cpp)
storage_fts_unittest(test_fts_plugin test_fts_plugin.cpp)
storage_fts_unittest(test_fts_property test_fts_property.cpp)
storage_unittest(test_storage_logger_manager slog/test_storage_logger_manager.cpp)
storage_unittest(test_storage_log_read_write slog/test_storage_log_read_write.cpp)
storage_unittest(test_storage_log_replay slog/test_storage_log_replay.cpp)
storage_unittest(test_linked_macro_block slog_ckpt/test_linked_macro_block.cpp)
storage_unittest(test_tenant_slog_ckpt_util slog_ckpt/test_tenant_slog_ckpt_util.cpp)
storage_unittest(test_tablet_dumped_medium_info test_tablet_dumped_medium_info.cpp)
#storage_unittest(test_log_stream_backup backup/test_log_stream_backup.cpp)
#storage_unittest(test_backup_ctx backup/test_backup_ctx.cpp)
storage_unittest(test_backup_utils backup/test_backup_utils.cpp)
storage_unittest(test_backup_tmp_file backup/test_backup_tmp_file.cpp)
storage_unittest(test_backup_data_struct backup/test_backup_data_struct.cpp)
storage_unittest(test_backup_index_cache backup/test_backup_index_cache.cpp)
storage_unittest(test_backup_iterator backup/test_backup_iterator.cpp)
storage_unittest(test_backup_index_merger backup/test_backup_index_merger.cpp)
storage_unittest(test_backup_extern_info_mgr backup/test_backup_extern_info_mgr.cpp)
#storage_unittest(test_backup_linked_item_write_and_read backup/test_backup_linked_item_write_and_read.cpp)
storage_unittest(test_backup_index_compressor backup/test_backup_index_compressor.cpp)
storage_unittest(test_backup_data_path backup/test_backup_data_path.cpp)
storage_unittest(test_backup_clean_set_selector backup/test_backup_clean_set_selector.cpp)
storage_unittest(test_backup_clean_utils backup/test_backup_clean_utils.cpp)
storage_unittest(test_backup_clean_piece_selector backup/test_backup_clean_piece_selector.cpp)
storage_unittest(test_backup_clean_piece_clog_block_dependency backup/test_backup_clean_piece_clog_block_dependency.cpp)
storage_unittest(test_backup_tablet_reorganize_helper backup/test_backup_tablet_reorganize_helper.cpp)
storage_unittest(test_backup_macro_block_index_merger backup/test_backup_macro_block_index_merger.cpp)
storage_unittest(test_backup_device_wrapper backup/test_backup_device_wrapper.cpp)
storage_unittest(test_backup_sync_io_mock_async_io backup/test_backup_sync_io_mock_async_io.cpp)
storage_unittest(test_backup_device_macro_block_id backup/test_backup_device_macro_block_id.cpp)
storage_unittest(test_backup_compatible backup/test_backup_compatible.cpp)
storage_unittest(test_backup_tmp_file_queue backup/test_backup_tmp_file_queue.cpp)
storage_unittest(test_backup_clean_path backup/test_backup_clean_path.cpp)

#storage_unittest(test_create_tablet_clog tx_storage/test_create_tablet_clog.cpp)
storage_unittest(test_safe_destroy_handler tx_storage/test_safe_destroy_handler.cpp)
storage_unittest(test_simple_rows_merger)
storage_unittest(test_global_iterator_pool)
storage_unittest(test_partition_incremental_range_spliter)
storage_unittest(test_partition_major_sstable_range_spliter)
storage_unittest(test_parallel_minor_dag)
storage_dml_unittest(test_partition_range_spliter)
storage_dml_unittest(test_major_rows_merger)
storage_dml_unittest(test_tablet tablet/test_tablet.cpp)
storage_unittest(test_medium_list_checker compaction/test_medium_list_checker.cpp)
storage_dml_unittest(test_ls_reserved_snapshot_mgr compaction/test_ls_reserved_snapshot_mgr.cpp)
storage_unittest(test_diagnose_info_mgr compaction/test_diagnose_info_mgr.cpp)
storage_unittest(test_protected_memtable_mgr_handle test_protected_memtable_mgr_handle.cpp)
storage_unittest(test_tablet_create_mds_ctx test_tablet_create_mds_ctx.cpp)
storage_unittest(test_ddl_sstable_macro_range_ob_producer test_ddl_sstable_macro_range_ob_producer.cpp)
storage_unittest(test_choose_migration_source_policy migration/test_choose_migration_source_policy.cpp)
storage_unittest(test_transfer_mds_ctx test_transfer_mds_ctx.cpp)
storage_unittest(test_rebuild_src test_rebuild_src.cpp)

if(OB_BUILD_CLOSE_MODULES)
storage_dml_unittest(test_compaction_policy)
endif()

if(OB_BUILD_CLOSE_MODULES)
  storage_unittest(test_lob_seq_id)
  storage_unittest(test_block_gc_handler)
  storage_unittest(test_detect_and_gc_block)
endif()
storage_unittest(test_sstable_log_ts_range_cut test_sstable_log_ts_range_cut.cpp)
storage_unittest(test_cg_bitmap column_store/test_cg_bitmap.cpp)
storage_unittest(test_co_sstable column_store/test_co_sstable.cpp)
storage_unittest(test_co_sstable_rows_filter column_store/test_co_sstable_rows_filter.cpp)
storage_unittest(test_compaction_iter compaction/test_compaction_iter.cpp)
